﻿using System;
using System.Activities.Presentation.Model;
using System.Activities.Presentation.Services;
using System.Activities.Presentation.View;

namespace Headsight.BPMN2WF.WF.Impl
{
    public static class ModelItemFactory
    {
        public static AbstractModelItem Create(ModelItem modelItem, ViewStateService viewStateService, ViewService viewService)
        {
            switch (modelItem.ItemType.Name)
            {
                case "Flowchart":
                    return new ModelItemFlowChart(modelItem, viewStateService, viewService);
                case "FlowDecision":
                    return new ModelItemFlowDecision(modelItem, viewStateService, viewService);
                case "FlowStep":
                    return new ModelItemFlowStep(modelItem, viewStateService, viewService);
                case "FlowSwitch`1":
                case "FlowSwitch":
                    return new ModelItemFlowSwitch(modelItem, viewStateService, viewService);
                default:
                    throw new Exception("Unknown ModelItem Type: " + modelItem.ItemType.Name);
            }
        }
    }
}
